package demo01;

public class Chengxu36 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        int m = 2;
        rotateArray(arr, m);
        for (int i : arr) {
            System.out.print(i + " ");
        }
    }

    public static void rotateArray(int[] arr, int m) {
        int n = arr.length;
        int[] temp = new int[m];
        for (int i = 0; i < m; i++) {
            temp[i] = arr[n - m + i];
        }
        for (int i = n - 1; i >= m; i--) {
            arr[i] = arr[i - m];
        }
        for (int i = 0; i < m; i++) {
            arr[i] = temp[i];
        }
    }
}
